package org.elephas.webapp.frontend.component;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;

/**
 * This header panel simply renders the title via the provided IModel;
 * 
 * @author Gerolf Seitz
 * 
 */
public class HeaderPanel extends Panel<String> {

	private static final long serialVersionUID = 1L;

	/**
	 * Constructs the {@link HeaderPanel}
	 * 
	 * @param id
	 *            the component id
	 * @param titleModel
	 *            the model used for the title label
	 */
	public HeaderPanel(String id, final IModel<String> titleModel,
			Class<? extends WebPage> pageClass, PageParameters params) {
		super(id, titleModel);
		add(new BookmarkablePageLink("title", pageClass, params) {
			private static final long serialVersionUID = 1L;

			@Override
			protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
				replaceComponentTagBody(markupStream, openTag, titleModel
						.getObject());
			}

		});		
	}

}
